package structure.filter;

import java.util.List;

/**
 * 并集
 *
 * @author yeyangtao
 * @date 2020/6/23 14:47
 */
public class OrCriteria implements Criteria {
    private Criteria criteria;
    private Criteria otherCriteria;

    public OrCriteria(Criteria criteria, Criteria otherCriteria) {
        this.criteria = criteria;
        this.otherCriteria = otherCriteria;
    }

    @Override
    public List<Person> meetCriteria(List<Person> list) {
        List<Person> result = criteria.meetCriteria(list);
        List<Person> temp = otherCriteria.meetCriteria(list);
        result.removeAll(temp);
        result.addAll(temp);
        return result;
    }
}
